﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HelpNetwork
{
    public  struct Param
    {
        public DateTime dataOraPreluarii;
        public char[] EKG;
        public struct HTAstruct
        {
            public UInt16 Sistolic;
            public UInt16 Diastolic;

        }
        public HTAstruct HTA;
        public UInt16 puls;
        public Byte tempCorp;
        public Byte tempAmbientala;
        public UInt16 greutate;
        public UInt16 glicemie;
        public UInt16 frecvResp;
        public bool lumina;
        public bool gaz;
        public bool umiditate;
        public bool RFID;
        public bool tensiuneRetea;

    };
    public struct Senzor
    {
        public int alarma;
        public int limitaSup;
        public int limitaInf;
    };

    public class Parametrii
    {
        public bool generareAutomata = false;
        public bool salvareDate = true;
        public String adresaDispecerat = "http://claudiaivan.com/ip";

        public Senzor EKG;
        public Senzor HTA;
        public Senzor Puls;
        public Senzor Greutate;
        public Senzor Glicemie;
        public Senzor FrecventaRespiratorie;
        public Senzor Gaz;
        public Senzor Umiditate;
        public Senzor RFID;
        public Senzor Tensiune;

        public Param parametriiCurenti;
        public Random RandomClass = new Random();



        public static void salvareDateAutentificare(ref String utilizator, ref String parola)
        {
            StreamWriter fisier = new StreamWriter("auth.cfg",false);
            fisier.WriteLine(utilizator);
            fisier.WriteLine(parola.GetHashCode());
            fisier.Close();
        }
        public static void citireDateAutentificare(ref String utilizator, ref String parola)
        { 
            StreamReader fisier = new StreamReader("auth.cfg");
            utilizator = fisier.ReadLine();
            parola = fisier.ReadLine();
            fisier.Close();
        }
        public static void stergereFisier()
        {
            StreamWriter fisier = new StreamWriter("auth.cfg", false);
            fisier.Close();
        }
        public static bool verificareFisier()
        {
            try
            {
                StreamReader fisier = new StreamReader("auth.cfg");
                if (fisier.Peek() == 0)
                {
                    fisier.Close();
                    return false;
                }
                else
                {
                    fisier.Close();
                    return true;
                }
            }
            catch (FileNotFoundException fnfException)
            {
                return false;
            }

        }


    }
}
